home *** CD-ROM | disk | FTP | other *** search
/ The Utilities Experience / The Utilities Experience - Volume 1.iso / software / comms / thor_2.22 / thor.lha / rexx / SaveRange.thor < prev    next >
Text File  |  1995-12-18  |  3KB  |  112 lines

  1. /* SaveRange.thor by Troels Walsted Hansen
  2. ** $VER: SaveRange.thor v2.00 (22.11.94)
  3. **
  4. ** Save a specified range of messages to disk.
  5. **
  6. ** New: · This version is only for THOR v2.0 or higher.
  7. **      · progressbar
  8. */
  9.  
  10. options results
  11.  
  12. /* needs THOR and bbsread.library functions */
  13.  
  14. p = address() || ' ' || show('P',,)
  15. thorport = pos('THOR.',p)
  16.  
  17. if thorport > 0 then thorport = word(substr(p,thorport),1)
  18. else
  19. do
  20.     say 'No THOR port found!'
  21.     exit 10
  22. end
  23.  
  24. if ~show('p', 'BBSREAD') then
  25. do
  26.     address command
  27.         "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  28.         "WaitForPort BBSREAD"
  29. end
  30.  
  31. /* get info on messages */
  32.  
  33. address(bbsread)
  34. GETGLOBALDATA stem GLOBALDATA
  35.  
  36. address(thorport)
  37. GETGLOBALCONFIG stem GLOBALCONFIG
  38. CURRENTBBS stem CURRENT
  39.  
  40. if(CURRENT.CONFNAME = "") then
  41. do
  42.     address(bbsread)
  43.         GETCONFLIST '"'CURRENT.BBSNAME'"' CONFLIST
  44.     if(rc ~= 0) then
  45.     do
  46.         address(thorport)
  47.         REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
  48.         exit 5
  49.     end
  50.  
  51.     address(thorport)
  52.     REQUESTLIST instem CONFLIST title '"Select conf:"' SIZEGADGET
  53.     if(rc ~= 0) then exit
  54.     else CURRENT.CONFNAME = result
  55. end
  56.  
  57. address(bbsread)
  58. GETCONFDATA bbsname '"'CURRENT.BBSNAME'"' confname '"'CURRENT.CONFNAME'"' stem CONFDATA
  59.  
  60. if(CONFDATA.FIRSTMSG < 1 | CONFDATA.LASTMSG < 1) then exit
  61.  
  62. address(thorport)
  63. REQUESTINTEGER MIN '"'CONFDATA.FIRSTMSG'"' MAX '"'CONFDATA.LASTMSG'"' INIT '"'CONFDATA.FIRSTMSG'"' TITLE '"First message in range:"' BT '"_Ok|_Cancel"'
  64. firstmsg = result
  65. if(rc ~= 0 | firstmsg = "RESULT") then exit
  66.  
  67. REQUESTINTEGER MIN '"'firstmsg'"' MAX '"'CONFDATA.LASTMSG'"' INIT '"'CONFDATA.LASTMSG'"' TITLE '"Last message in range:"' BT '"_Ok|_Cancel"'
  68. lastmsg = result
  69. if(rc ~= 0 | lastmsg = "RESULT") then exit
  70.  
  71. REQUESTFILE TITLE '"Select directory for messages:"' ID '"'GLOBALCONFIG.SAVEDIR'"' FP PAT '"~"'
  72. if(rc ~= 0 | result = "") then exit
  73. else dir = result
  74.  
  75. /* if user selected a file instead (silly user) reduce it to dirname */
  76.  
  77. endchar = right(dir,1)
  78.  
  79. if(endchar ~= ":" & endchar ~= "/") then do
  80.     posi = lastpos("/",dir)
  81.     if(posi = 0) then posi = lastpos(":",dir)
  82.     dir = delstr(dir,posi+1)
  83. end
  84.  
  85. /* change the illegal filename characters ":" and "/" into "." */
  86.  
  87. if(pos("/",CURRENT.CONFNAME) ~= 0 | pos(":",CURRENT.CONFNAME) ~= 0) then
  88.     newconfname = translate(CURRENT.CONFNAME,"..","/:")
  89. else newconfname = CURRENT.CONFNAME
  90.  
  91. /* save the messages with a progressbar */
  92.  
  93. OPENPROGRESS TITLE '"' || 'Saving messages from ' || CURRENT.CONFNAME || '"' TOTAL lastmsg-firstmsg+1 AT '"_Abort"'
  94. if(rc = 0) then
  95. do
  96.     window = result
  97.  
  98.     do i=firstmsg to lastmsg
  99.         UPDATEPROGRESS REQ window CURRENT i-firstmsg+1 PT '"' || 'Saving message #' || i || '"'
  100.         if(rc ~= 0) then
  101.         do
  102.             CLOSEPROGRESS REQ window
  103.             exit
  104.         end
  105.  
  106.         SAVEMESSAGE BBS '"'CURRENT.BBSNAME'"' CONF '"'CURRENT.CONFNAME'"' MSGNR '"'i'"' FILE '"'||dir||newconfname||'.'||i||'"'
  107.     end
  108. end
  109. CLOSEPROGRESS REQ window
  110.  
  111. exit
  112.